{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item" >

                        <div class="layui-input-inline layui-form">
                            组别：
                            <select name="group_id" id="role" lay-search="">
                                <option  value="">全部组别</option>
                                {foreach name="group" item="vo"}
                                <option  value="{$vo.mg_id}">{$vo.mg_name}</option>
                                {/foreach}
                            </select>
                        </div>

                        <div class="layui-input-inline layui-form">
                            船型：
                            <select name="boat_type" id="boat_type" lay-search="">
                                <option  value="">全部船型</option>
                                <option  value="1">1x</option>
                                <option  value="2">2-</option>
                                <option  value="3">2+</option>
                                <option  value="4">4-</option>
                                <option  value="5">4+</option>
                                <option  value="6">4x</option>
                                <option  value="7">2x</option>
                                <option  value="8">8+</option>
                            </select>
                        </div>

                        <div class="layui-input-inline layui-form">
                            赛道距离：
                            <select name="distance" id="distance" lay-search="">
                                <option  value="">全部距离</option>
                                <option  value="500">500</option>
                                <option  value="1000">1000</option>
                                <option  value="1500">1500</option>
                                <option  value="2000">2000</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 18px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>
                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group" >
                        <button  class="btn btn-danger m-l-xs layuiBtn" data-type="chouQ">
                            抽签
                        </button>
                        <!--<button class="btn btn-primary" type="button">-->
                            <!--<a class="J_menuItem" href="http://new4.xuanwumobile.com/fenpei/index.html" target="_blank">抽签</a>-->
                        <!--</button>-->
                        <!--<button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">-->
                        <!--<i class="fa fa-wrench"></i> 抽签 <span class="caret"></span>-->
                        <!--</button>-->
                        <!--<ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">-->
                        <!--<li><a href="javascript:;" class="layuiBtn" data-type="chouQ"> 抽签 </a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="batchClose"><i class="fa fa-check-circle"></i> 批量关闭订单</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="batchDel"><i class="fa fa-ban"></i> 批量删除订单</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-external-link"></i> 批量导出</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"><i class="fa fa-external-link"></i> 全部导出</a></li>-->
                        <!--</ul>-->
                    </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>

                    <!--状态显示模板-->
                    <script type="text/html" id="boatType">
                        {{# if(d.ma_boat_type == 1){ }}
                        1x
                        {{# } }}
                        {{# if(d.ma_boat_type == 2){ }}
                        2-
                        {{# } }}
                        {{# if(d.ma_boat_type == 3){ }}
                        2+
                        {{# } }}
                        {{# if(d.ma_boat_type == 4){ }}
                        4-
                        {{# } }}
                        {{# if(d.ma_boat_type == 5){ }}
                        4+
                        {{# } }}
                        {{# if(d.ma_boat_type == 6){ }}
                        4x
                        {{# } }}
                        {{# if(d.ma_boat_type == 7){ }}
                        2x
                        {{# } }}
                        {{# if(d.ma_boat_type == 8){ }}
                        8+
                        {{# } }}
                    </script>

                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('组次','{:url('writeZu')}?ma_id={{d.ma_id}}')" class="btn btn-warning btn-xs m-r-xs" title="填写组次">填写组次</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<textarea id="allidsForOut" class="hidden"></textarea>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Chouq/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30, 100]
            , limit: 100
            , loading: true
            , id: 'testReload'
            , cols: [[
//                  {type: 'checkbox', fixed: 'left'}
                  {type:'numbers', width: '', title: '序号'}
                , {field: 'ma_team_name', width: 100, title: '队名', align: 'center'}
                , {field: 'mg_name', width: '', title: '组别', align: 'center'}
                , {field: 'ma_boat_type', width: 80, title: '船型', align: 'center', toolbar: '#boatType'}
                , {field: 'ma_distance', width: 100, title: '赛道距离', align: 'center'}
                , {field: 'club_name', width: '', title: '代表队', align: 'center'}
                , {field: 'mr_name', width: 90, title: '组次', align: 'center', edit: 'test'}
                , {field: 'mt_name', width: 80, title: '轮次', align: 'center', edit: 'test'}
                , {field: 'ma_dao_num', width: 80, title: '赛道', align: 'center'}
                , {field: 'ma_lots', width: 90, title: '抽签序号', align: 'center'}
//                , {fixed: 'right', width: 140, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('#allidsForOut').val(res.where_str);
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
        //监听单元格编辑---排序
        table.on('edit(testReload)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
            wk.change(data.ma_id,"{:url('updateChang')}",field,value);
        });

        // 抽签
        var $ = layui.$, active = {
            //抽签
            chouQ:function () {
                wk.chouQ($('#allidsForOut').val(),$('.layui-input').serialize(),"{:url('chouQian')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['match_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>